1. Field of the Invention
The present invention relates to automatic generation of code in a higher level language (such as C or C++), with the generated code thereafter being compilable so as to obtain an executable to implement a printer driver.
2. Description of the Related Art
During initial development and writing of computer programs, software developers have come to rely on automatic code generators to generate source code in a high-level language (such as C or C++) that implements basic functionality of the new computer program. The code generator is, itself, a computer program that leads the software developer through a question-and-answer session, inquiring into the desired functionality of the new software, and thereafter generating source code to implement such functionality after the questions have been answered. After obtaining the generated source code from the code generator, the software developer can compile the software so as to obtain an executable which is a basic working version of his desired software. The source code can also be modified by the software developer so as to implement more specific aspects of the new software. Code generators are sometimes referred to as xe2x80x9cwizardsxe2x80x9d, and have been designed to generate code in any of a variety of high-level languages such as C, C++, Visual Basic, COBOL, Fortran, Pascal, PL/1, Mesa, ADA, and other non-object source code.
One technological area where automatic code generators have not generally been applied is the area of device drivers such as printer drivers. One reason for this is as follows: to obtain the highest quality printed output for modern day printers, printer drivers typically employ techniques that are unique for each individual manufacturer and model of printer, and these techniques are generally proprietary. Since automatic code generators generate source code, such techniques would be immediately apparent, rendering them non-proprietary. For example, in the case of color ink jet printers, color conversion techniques and halftone processing often employ specifics that are proprietary to the manufacturer of the printer.
Moreover, even to the extent that automatic code generators for printer drivers might be available, they are available only for interface to the GDI kernel of the Windows(copyright) operating system from Microsoft Corporation. Resulting printer drivers are therefore not compatible with other operating systems, such as the UNIX operating system and real-time operating systems such as WindRiver""s Vx Works(trademark) and Integrated Systems"" pSOS(trademark). These other operating systems, since they do not insulate the printer driver from the physical printer port like the Windows(copyright) GDI kernel, require printer drivers to be independently executable modules which access directly to the printer port.
These other operating systems also do not necessarily insulate the printer driver from system resources in the same way as the Windows(copyright) operating system. Depending on the operating system, the printer driver must directly access these system resources. For example, the printer driver might need to directly access input devices such as an image input device and user input devices (e.g., a mouse and a keyboard), memory management resources, process control resources, resource locking resources, output devices such as a display, storage devices such as a hard disk, and any other resources required for operation of the printer driver. These system resources typically are accessed either through a port or through an operating system function. These system resources can be implemented in hardware, or in software as operating system functions. The printer driver also might need to access other operating system functions such as controlled printed job termination functions and any other system functions that access system resources in ways that differ from one operating system to another. In addition, the printer driver might contain customized equivalents of these operating system functions.
The printer driver must know how to access these ports, including the printer port, and these operating system functions. In a case that the printer driver includes customized equivalents to operating system functions, the printer driver must know how to interact with the operating system in order to execute these equivalents.
It is therefore an object of the invention to provide a code generator for a printer driver which automatically generates source code for a printer driver that is compilable into an executable that directly accesses the printer port, and that accesses any other necessary ports and operating system functions, while at the same time shielding the software developer from any proprietary techniques for driving the printer.
Briefly, according to one aspect of the invention, an automatic code generator for a printer driver obtains, from the software developer, the design parameters for the printer driver. Design parameters generally concern input processing, user interface and output functionality. The design parameters can be obtained through an interactive question-and-answer session with the developer, through a database, through a script, or through other equivalent means.
Examples of parameters for input functionality include image input type and format. Parameters for processing functionality include, for example, complexity and flexibility of color transform and matching techniques available to the end user of the software, halftoning techniques such as selection between dither or error diffusion, and spooling support. Examples of parameters for user interface functionality include whether input from the end user is to be accepted, if a graphical interface is to be used for such input, and the design of such an interface. Parameters for output functionality include, for example, output format such as bitmap or one of several available page description languages (such as PCL5 or PostScript), font support and recording medium support (such as plain paper or transparency in the context of computer-aided tomography equipment).
The software developer also needs to provide a pointer to a function that interfaces directly to the printer port so that the printer driver can send print data to the printer port. Specifically, because each different operating system, and each different system in which the operating system resides, employs a different printer port and different printer port protocol, it is necessary for the software developer himself to provide a printer port function that actually interfaces to the printer port. According to the invention, the code generator generates source code that includes a call to this function whenever the printer driver needs to output printer data.
In addition to calling a printer port function, the printer driver might need to access system resources. Each different operating system, and each different system in which the operating system resides, can employ different ports and/or operating system functions for accessing system resources, and indeed the software developer may have written customized equivalents to such operating system functions. It is therefore necessary for the software developer himself to provide pointers to functions that access the ports or call the operating system functions that actually interface to these resources. According to the invention, the source code includes calls to the functions identified by these pointers whenever the printer driver needs to access the system resources. For example, in order to access system resources such as memory allocation or release, the generated code includes a call to the appropriate function using a pointer provided by the software developer. That function, in turn, accesses the system resource through the appropriate port or operating system function.
In further aspects of the invention, the source code generated by the code generator does not include source code relating to proprietary printer functions, such as proprietary color matching or halftoning techniques. Instead, such functions are provided to the software developer in pre-compiled library format, to which compiled source code may be linked. Accordingly, rather than generating source code with proprietary printer functions, the code generator of the present invention generates source code uses the functions in the library to implement such proprietary functions. Preferably, the generated source code includes variable definitions, such as for a table of printer operations, and this table is used by functions in the library so as to determine how to execute a printer driver. Alternatively, the source code includes calls to functions in the library to implement the printer driver.
Because the code generator of the present invention merely generates variable definitions for or calls to proprietary printer functions in a pre-compiled library, it is possible to provide software developers with a code generation tool that allows them quickly to generate printer drivers while shielding them from unnecessary disclosure of proprietary printer functionality.
Moreover, since it is the software developer who provides the functions (by providing pointers to the functions) that interface directly to the printer port and system resources such as memory allocation, the code generator according to the invention is easily portable from one operating system to another, and from one system implementing such operating systems to other such systems.
As an example, assume that the code generator determines, based on the functional design parameters, that pointers are needed to a printer port function, a memory management function, and a user input/output function. In that case, the printer port function directly accesses the physical printer port using the appropriate protocols for the operating system on which the printer driver runs. The memory management function calls operating system functions that handle memory management. Alternatively, the memory management function is a customized function that handles memory management. The user input/output function either calls operating system functions for user input/output, or directly accesses input and output devices through the appropriate ports.
In another aspect, the invention is a code generator together with a pre-compiled library of proprietary printer functions having entry points accessible by a link editor. The code generator obtains design parameters for a printer driver, the design parameters including parameters relating to input functionality, output functionality, user interface functionality, and print data processing functionality. In addition, the code generator obtains a pointer to a system function that interfaces directly to a system resource such as a physical printer port. Preferably, the code generator also obtains an other pointer to an other function that uses a port or an operating system function to access a system resource. Thereafter, the code generator generates source code in a high-level language such as C, C++, Visual Basic, COBOL, Fortran, Pascal, PL/1, Mesa, ADAC, or any other non-object source code, with the source code implementing the design parameters by including variable definitions for or calls to appropriate ones of the functions in the pre-compiled library, and by including a pointer for or a call to the printer port function that causes printer data to be output to the printer port. Preferably, the source code also includes a pointer for or a call to the other function. Thereafter, the generated source code may be compiled by a standard compiler into a compiled object, and the compiled object can be linked by a link editor with the pre-compiled library of functions, so as to yield an executable which implements desired printer functionality.
The present invention can be used to generate source code for a printer driver for many different systems. For example, the printer driver could be for use with so-called embedded systems. Examples of products that can have embedded systems therein include personal data assistants, WebTV boxes, digital camera converters, telephones, kiosks, game consoles, special purpose (and typically hand-held) devices used by package shipment personnel, supermarket clerks, and civil engineers, and special purpose desktop devices such as cash registers, computer-aided tomography (CAT) devices, and other medical imaging devices. Many other such devices exist.
This brief summary has been provided so that the nature of the invention may be understood quickly. A more complete understanding of the invention can be obtained by reference to the following detailed description of the preferred embodiment thereof in connection with the attached drawings.